package org.skatiger.jrove.component.html;

import org.skatiger.jrove.renderer.Html;
import org.skatiger.jrove.util.AssertUtil;
import org.skatiger.jrove.util.StringUtils;

public class Navigation extends HtmlComponentBase {
    public static final String DEFAULT_NAVIGATION_ELEMENT = Html.UL_ELEM;
    public static final String DEFAULT_AVTIVE_ITEM_NAME_SUFFIX = ".active";

    private String alias;
    private String activeClass;
    private String activeItemId;

    public String getActiveClass() {
        return getPropertyValue("activeClass", activeClass);
    }

    public void setActiveClass(String activeClass) {
        this.activeClass = activeClass;
    }

    public String getAlias() {
        return getPropertyValue("alias", alias, DEFAULT_NAVIGATION_ELEMENT);
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getActiveItemId() {
        return activeItemId;
    }

    public void setActiveItemId(String activeItemId) {
        this.activeItemId = activeItemId;
    }

    public String getActiveItemName() {
        return getId() + DEFAULT_AVTIVE_ITEM_NAME_SUFFIX;
    }

    public boolean isActive(String itemId) {
        AssertUtil.notNull(itemId);
        if (StringUtils.isNotBlank(activeItemId)) {
            return itemId.equals(activeItemId);
        }
        return false;
    }
}
